<template>
	<div v-cloak class="aui-wrapper aui-page__iframe">
		<div class="aui-content__wrapper">
			<div class="aui-content">
				<el-card shadow="never" class="aui-card--fill">
					<div class="mod-lswms__receiptdetaillist">
						<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
							<el-form-item>
								<el-input size="small" v-model="dataForm.receiptkey" placeholder="入库单号" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input size="small" v-model="dataForm.line" placeholder="明细行" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input size="small" v-model="dataForm.sku" placeholder="物料编码" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input size="small" v-model="dataForm.descr" placeholder="物料名称" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-input size="small" v-model="dataForm.lot6" placeholder="计划单号" clearable></el-input>
							</el-form-item>
							<el-form-item>
								<el-button size="small" @click="getDataList()">查询</el-button>
							</el-form-item>
							<!-- <el-form-item>
                            <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
                          </el-form-item> -->
							<!--<el-form-item>
                            <el-button type="danger" @click="deleteHandle()">删除</el-button>
                          </el-form-item>-->
                          <el-form-item>
                            <el-button  size="small" type="info" @click="exportHandle()">导出</el-button>
                          </el-form-item>
						</el-form>
						<el-table v-loading="dataListLoading" :data="dataList" border
							@selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
							style="width: 100%;">
							<!-- <el-table-column type="selection" header-align="center" align="center" width="50">
							</el-table-column> -->
							<!-- <el-table-column prop="id" label="序号11111"  header-align="center"
                                           align="center"></el-table-column> -->
							<el-table-column prop="receiptkey" label="入库单号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="line" label="明细行号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="linelist" label="明细记录行号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="statusstr" label="状态" header-align="center" align="center"></el-table-column>
							<el-table-column prop="sku" label="物料编码" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="descr" label="物料名称" header-align="center" align="center"></el-table-column>
							<el-table-column prop="factorycdoe" label="计量编码/工装号" header-align="center" align="center"></el-table-column>
							<el-table-column prop="unit" label="单位" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="pack" label="包装" header-align="center" align="center">
							</el-table-column>
							<!-- <el-table-column prop="status" label="状态" header-align="center" align="center">
							</el-table-column> -->
							
							<el-table-column prop="qty" label="预计数量" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="actqty" label="实际数量" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="toloc" label="目的库位" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="totray" label="目的箱" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="boxstr" label="目的格" header-align="center" align="center">
							</el-table-column>
							<!-- <el-table-column prop="lot" label="批号"  header-align="center"
                                           align="center"></el-table-column> -->
							<el-table-column prop="lot1" label="生产日期" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot2" label="有效日期" header-align="center" align="center">
							</el-table-column>
							<!-- <el-table-column prop="lot3" label="属性3" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot4" label="属性4" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot5" label="属性5" header-align="center" align="center">
							</el-table-column>
							-->
							<el-table-column prop="lot6" label="计划单号" header-align="center" align="center">
							</el-table-column>
							<!--
							<el-table-column prop="lot7" label="属性7" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot8" label="属性8" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot9" label="属性9" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="lot10" label="属性10" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="remark" label="备注" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="sourcekey" label="来源单号" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="sourcetype" label="来源单类型" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="sourcedate" label="来源单时间" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="relatedorderkey" label="关联单据" header-align="center" align="center">
							</el-table-column>
							<el-table-column prop="relatedorderline" label="关联单据行" header-align="center" align="center">
							</el-table-column> -->
							
							<el-table-column type="expand" label="详情" fixed="right">
								<template #default="props">
									<el-form label-position="left" inline class="demo-table-expand">
										<el-row>
											<el-col :span="4">
												<el-form-item label="批号:">
													<span>{{ props.row.lot }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="是否加长:">
													<span>{{ props.row.lot3 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="价格:">
													<span>{{ props.row.lot4 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="部门/供应商:">
													<span>{{ props.row.lot5 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="计划单号/工序号:">
													<span>{{ props.row.lot6 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="主制车间:">
													<span>{{ props.row.lot7 }}</span>
												</el-form-item>
											</el-col>
										</el-row>
										<el-row>
											<el-col :span="4">
												<el-form-item label="任务编码:">
													<span>{{ props.row.lot8 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="新旧:">
													<span>{{ props.row.lot9 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="作废:">
													<span>{{ props.row.lot10 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="炉批号:">
													<span>{{ props.row.lot11 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="材料复验号:">
													<span>{{ props.row.lot12 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="牌号:">
													<span>{{ props.row.lot13 }}</span>
												</el-form-item>
											</el-col>
											</el-row>
											<el-row>
											<el-col :span="4">
												<el-form-item label="属性14:">
													<span>{{ props.row.lot14 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="属性15:">
													<span>{{ props.row.lot15 }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="来源单号:">
													<span>{{ props.row.sourceke }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="来源类型:">
													<span>{{ props.row.sourcetype }}</span>
												</el-form-item>
											</el-col>
							
											<el-col :span="4">
												<el-form-item label="来源单据:">
													<span>{{ props.row.relatedorderkey }}</span>
												</el-form-item>
											</el-col>
									
											<el-col :span="4">
												<el-form-item label="来源单行:">
													<span>{{ props.row.relatedorderline }}</span>
												</el-form-item>
											</el-col>
											</el-row>
											<el-row>
											<el-col :span="4">
												<el-form-item label="来源时间:">
													<span>{{ props.row.sourcedate }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="创建人:">
													<span>{{ props.row.adduser }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="创建时间:">
													<span>{{ props.row.addtime }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="更新人:">
													<span>{{ props.row.updatuser }}</span>
												</el-form-item>
											</el-col>
											<el-col :span="4">
												<el-form-item label="更新时间:">
													<span>{{ props.row.updatetime }}</span>
												</el-form-item>
											</el-col>
										</el-row>
									</el-form>
								</template>
							</el-table-column>
							
							<!-- <el-table-column prop="backstatus" label="回传状态"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="backdate" label="回传时间"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="backresult" label="回传结果"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="backcode" label="回传码"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="warehouse" label="仓库"  header-align="center"
                                           align="center"></el-table-column>
													<el-table-column prop="adduser" label="创建人"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="addtime" label="创建时间"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="updatuser" label="更新人"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="updatetime" label="更新时间"  header-align="center"
                                           align="center"></el-table-column> -->
							<!--<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
                           <template #default="scope">
                              <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
                              <el-button type="text" size="small" @click="deleteHandle2(scope.row.id)">删除</el-button>
                            </template>
                          </el-table-column>-->
						</el-table>
						<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit"
							:total="total" layout="total, sizes, prev, pager, next, jumper"
							@size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
						</el-pagination>
						<!-- 弹窗, 新增 / 修改 -->
						<receiptdetaillistAddOrUpdate v-if="addOrUpdateVisible" ref="addOrUpdate"
							@refresh-data-list="getDataList"></receiptdetaillistAddOrUpdate>
					</div>
				</el-card>
			</div>
		</div>
	</div>
</template>

<script>
	import DataList from "@/utils/DataList";
	import {
		ref,
		reactive,
		onMounted,
		nextTick
	} from 'vue';
	import receiptdetaillistAddOrUpdate from "@/components/lswms/receipt/ReceiptdetaillistAddOrUpdate";
	import {
		getReceiptdetaillistById
	} from "../../../network/lswms/receipt/Receiptdetaillist";
	import {
		revoke
	} from "../../../network/lswms/receipt/Receiptdetaillist";
	import {
		ElMessage,
		ElMessageBox
	} from "element-plus";
	//import {hasPermission} from "@/utils/hasPermission"
	export default {
		name: "receiptdetaillist",
		props: {
			dataForm: {
				type: Object
			}
		},
		components: {
			receiptdetaillistAddOrUpdate,
		},

		setup() {
			const {
				order,
				orderField,
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate
			} = DataList();



			const deleteHandle2 = (id) => {
				ElMessageBox.confirm('确定关闭选择的单据吗?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(function() {
					getReceiptdetaillistById(id).then((res) => {
						revoke(res.data).then(function(res) {
							if (res.code !== 0) {
								return ElMessage.error(res.msg);
							}
							ElMessage({
								message: '操作成功',
								type: 'success',
								duration: 500,
								onClose: function() {
									getDataList();
								}
							});
						})
						/*deleteHandle(id);*/
					})
				})
			}
			onMounted(() => {
				dataForm.value = {

					receiptkey: '',

				}
				order.value = 'desc',
					orderField.value = 'receiptkey',
					mixinViewModuleOptions.value.getDataListIsPage = true;
				mixinViewModuleOptions.value.getDataListURL = '/lswms/receiptdetaillist/page';
				mixinViewModuleOptions.value.deleteURL = '/lswms/receiptdetaillist';
				mixinViewModuleOptions.value.exportURL = '/lswms/receiptdetaillist/export';
				mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
				mixinViewModuleOptions.value.deleteIsBatch = true;

				/*console.log(props.dataForm.receiptkey)*/
				/*dataForm.value.receiptkey=props.dataForm.receiptkey*/


				if (mixinViewModuleOptions.value.activatedIsNeed) {

					getDataList();
				}

			})

			return {

				order,
				orderField,
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,
				deleteHandle2
			}
		},
		// methods:{
		// 	hasPermission
		// }
	}
</script>

<style scoped>

</style>
